<template>
  <div class="comment" v-if="Object.keys(commentInfo).length !== 0">
    <div class="commentheader">
        <div class="title">用户评价</div>
    </div>
    <!-- 用户信息 -->
    <div class="user">
        <img :src="commentInfo.user.avatar" alt="">
        <span>{{commentInfo.user.uname}}</span>
    </div>
    <!-- 用户评论 -->
    <div class="detail">
        <p>{{commentInfo.content}}</p>
        <div class="other">
          <!-- 时间,要用过滤器转换一遍 -->
          <span class="date">{{commentInfo.created | showdata}}</span>
          <span>{{commentInfo.style}}</span>
        </div>
        <!-- 评论图片 -->
        <div class="imgs">
          <img :src="item" v-for="(item, index) in commentInfo.images">
        </div>
      </div>
  </div>
</template>

<script>
// 导入函数
import { formatDate } from 'common/utils.js'
export default {
  name: 'detailcommentinfo',
  props: {
    commentInfo: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  filters: {
		  // eslint-disable-next-line object-shorthand
		  showdata: function(value) {
      let date = new Date(value*1000);
      return formatDate(date, 'yyyy-MM-dd')
    }
  }
}
</script>

<style lang="stylus" scoped>
.comment
  padding 5px 12px
  border-bottom 5px solid #f2f5f8
  .commentheader
    height: 50px
    line-height: 50px
    border-bottom: 1px solid rgba(0,0,0,.1)
    .title
      float: left
      font-size: 15px
  .user
    padding 10px 0 5px 0
    display: flex
    align-items: center
    img
      width 42px
      height 42px
      border-radius 50%
      overflow hidden
    span
      margin-left 5px
      font-size 15px
      color #333
      vertical-align center
  .detail
    padding: 0 5px 15px
    p
      font-size: 14px
      color: #777
      line-height: 1.5
    .other
      font-size: 12px
      color: #999
      margin-top: 10px
      .date
        margin-right: 8px
  .imgs
    margin-top: 10px
    img
      width: 70px
      height: 70px
      margin-right: 5px
</style>